﻿using CKS2320.Common.Model;
using CKS2320.Service.Interface;
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Ocsp;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace CKS2320.WebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class CksLargeTotalController : ControllerBase
    {
        private ICksLargeTotalService _service;
        public CksLargeTotalController(ICksLargeTotalService cksLargeTotalService)
        {
            _service = cksLargeTotalService;
        }
        [HttpPost("GetTotalData")]
        public IActionResult GetTotalData(TotalReq totalReq)
        {
            return Ok(_service.GetTotalData(totalReq));
        }
        /// <summary>
        /// 获取检测列表数据
        /// </summary>
        /// <param name="totalReq"></param>
        /// <returns></returns>
        [HttpPost("DetectionHistory")]
        public IActionResult DetectionHistory(TotalReq totalReq)
        {
            return Ok(_service.DetectionHistory(totalReq));
        }
        /// <summary>
        /// 获取检测列表数据
        /// </summary>
        /// <param name="totalReq"></param>
        /// <returns></returns>
        [HttpPost("DetectionHistoryNew")]
        public IActionResult DetectionHistoryNew(TotalReq totalReq)
        {
            return Ok(_service.DetectionHistoryNew(totalReq));
        }
        /// <summary>
        /// 历史数据趋势
        /// </summary>
        /// <param name="req"></param>
        [HttpPost("HistoryDataTrends")]
        public IActionResult HistoryDataTrends(TrendsReq req)
        {
            return Ok(_service.HistoryDataTrends(req));
        }
        /// <summary>
        /// 检测记录导出
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost("ExportQueryList")]
        public IActionResult ExportQueryList(TotalReq req)
        {
            try
            {
                var ar = _service.ExportQueryList(req);
                if (ar.Code == 1)
                {
                    return ar.Data;
                }
                return Ok(ar.Message);
            }
            catch (Exception ex)
            {
                return Ok(ex.Message);
            }
        }
        /// <summary>
        /// 获取检测列表数据
        /// </summary>
        /// <param name="totalReq"></param>
        /// <returns></returns>
        [HttpPost("ExportQueryListNew")]
        public IActionResult ExportQueryListNew(TotalReq totalReq)
        {
            try
            {
                var ar = _service.ExportQueryListNew(totalReq);
                int a=0;
                if (ar.Code == 1)
                {
                    return ar.Data;
                }
                return Ok(ar.Message);
            }
            catch (Exception ex)
            {
                return Ok(ex.Message);
            }
        }
        /// <summary>
        /// 获取膜厚
        /// </summary>
        /// <param name="totalReq"></param>
        /// <returns></returns>
        [HttpPost("GetThicknessList")]
        public IActionResult GetThicknessList(TotalReq totalReq)
        {
            return Ok(_service.GetThicknessList(totalReq));
        }
        /// <summary>
        /// 获取检测列表数据
        /// </summary>
        /// <param name="totalReq"></param>
        /// <returns></returns>
        [HttpPost("ExportQuerydetails")]
        public IActionResult ExportQuerydetails(TotalReq totalReq)
        {
            try
            {
                var ar = _service.ExportQuerydetails(totalReq);
                if (ar.Code == 1)
                {
                    return ar.Data;
                }
                return Ok(ar.Message);
            }
            catch (Exception ex)
            {
                return Ok(ex.Message);
            }
        }
        /// <summary>
        /// 获取指标公差带
        /// </summary>
        [HttpGet("GetIndicatorToleranceZones")]
        public IActionResult GetIndicatorToleranceZones()
        {
            return Ok(_service.GetIndicatorToleranceZones());
        }
        [HttpPost("Push")]
        public IActionResult GetToDoMesData()
        {
            return Ok(_service.GetToDoMesData());
        }
    }
}
